package com.itheima.imclient100.presenter.impl;

import com.hyphenate.chat.EMClient;
import com.itheima.imclient100.presenter.SplashPresenter;
import com.itheima.imclient100.view.SplashView;

/**
 * Created by fullcircle on 2017/7/2.
 */

public class SplashPresenterImpl implements SplashPresenter {

    private SplashView splashView;

    public SplashPresenterImpl(SplashView splashView) {
        this.splashView = splashView;
    }

    @Override
    public void getLoginState() {
        //获取环信客户端对象
        EMClient emClient = EMClient.getInstance();
       if(emClient.isLoggedInBefore()&&emClient.isConnected()){
           //isLoggedInBefore 之前是否登录过
           //isConnected 是否和服务端建立了连接 如果都是true的话 直接进入主页面
           splashView.onGetLoginState(true);
       }else{
           //进入登录页面
           splashView.onGetLoginState(false);
       }
    }
}
